package com.ytktt.study.week7.task9.ds.context;

/**
 * 动态数据源路由线程上下文
 *
 * @author ytk
 */
public class DynamicDataSourceContext {

    public static final ThreadLocal<String> ROUTING_KEY_THREAD_LOCAL = new ThreadLocal<>();

    public static void setDataSourceRoutingKey(String dataSourceName) {
        ROUTING_KEY_THREAD_LOCAL.set(dataSourceName);
    }

    public static String getDataSourceRoutingKey() {
        return ROUTING_KEY_THREAD_LOCAL.get();
    }

    public static void clearRoutingThreadLocal() {
        ROUTING_KEY_THREAD_LOCAL.remove();
    }
}
